package com.easy;

/**
 * Created by Lxk on 2020/2/23.
 */
class VersionControl {

    public boolean isBadVersion(int version) {
        if (version > 10) {
            return true;
        }
        return false;
    }
}

class Solution2 extends VersionControl {

    public int firstBadVersion(int n) {
        int low = 0, high = n;
        while (low < high) {
            int mid = low + (high - low) / 2;
            if (isBadVersion(mid)) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return low;
    }
}

public class Solution278 {

    public static void main(String[] args) {
        Solution2 solution = new Solution2();
        System.out.println(solution.firstBadVersion(100));
    }
}
